
*******************************************************************************************
*******************************************************************************************
******************** Reclassification Risk in the Small Group Health Insurance Market
******************* by Sebastian Fleitas, Gautam Gowrisankaran and Anthony Lo Sasso 
*******************************************************************************************
*******************************************************************************************
*******************************************************************************************
******************** Table 5 HHW
*******************************************************************************************
*******************************************************************************************
*******************************************************************************************

 
version 15
clear all
set obs 7
egen type1 = seq()
gen aux = 7 
expand aux 
drop aux
bys type1 : egen type2 = seq()

*create premiums period 1
gen 	premiums1 =	2330	if type1==	1
replace	premiums1 =	3174	if type1==	2
replace	premiums1 =	3964	if type1==	3
replace	premiums1 =	5102	if type1==	4
replace	premiums1 =	6559	if type1==	5
replace	premiums1 =	9596	if type1==	6
replace	premiums1 =	20507	if type1==	7

* gen premiums period 2 
gen 	premiums2=	2512	if type1==	1	& 	type2==	1
replace 	premiums2=	2839	if type1==	1	& 	type2==	2
replace 	premiums2=	2839	if type1==	1	& 	type2==	3
replace 	premiums2=	2839	if type1==	1	& 	type2==	4
replace 	premiums2=	2839	if type1==	1	& 	type2==	5
replace 	premiums2=	2839	if type1==	1	& 	type2==	6
replace 	premiums2=	2839	if type1==	1	& 	type2==	7
replace 	premiums2=	2512	if type1==	2	& 	type2==	1
replace 	premiums2=	3321	if type1==	2	& 	type2==	2
replace 	premiums2=	3683	if type1==	2	& 	type2==	3
replace 	premiums2=	3683	if type1==	2	& 	type2==	4
replace 	premiums2=	3683	if type1==	2	& 	type2==	5
replace 	premiums2=	3683	if type1==	2	& 	type2==	6
replace 	premiums2=	3683	if type1==	2	& 	type2==	7
replace 	premiums2=	2512	if type1==	3	& 	type2==	1
replace 	premiums2=	3321	if type1==	3	& 	type2==	2
replace 	premiums2=	4087	if type1==	3	& 	type2==	3
replace 	premiums2=	4473	if type1==	3	& 	type2==	4
replace 	premiums2=	4473	if type1==	3	& 	type2==	5
replace 	premiums2=	4473	if type1==	3	& 	type2==	6
replace 	premiums2=	4473	if type1==	3	& 	type2==	7
replace 	premiums2=	2512	if type1==	4	& 	type2==	1
replace 	premiums2=	3321	if type1==	4	& 	type2==	2
replace 	premiums2=	4087	if type1==	4	& 	type2==	3
replace 	premiums2=	5196	if type1==	4	& 	type2==	4
replace 	premiums2=	5611	if type1==	4	& 	type2==	5
replace 	premiums2=	5611	if type1==	4	& 	type2==	6
replace 	premiums2=	5611	if type1==	4	& 	type2==	7
replace 	premiums2=	2512	if type1==	5	& 	type2==	1
replace 	premiums2=	3321	if type1==	5	& 	type2==	2
replace 	premiums2=	4087	if type1==	5	& 	type2==	3
replace 	premiums2=	5196	if type1==	5	& 	type2==	4
replace 	premiums2=	6628	if type1==	5	& 	type2==	5
replace 	premiums2=	7068	if type1==	5	& 	type2==	6
replace 	premiums2=	7068	if type1==	5	& 	type2==	7
replace 	premiums2=	2512	if type1==	6	& 	type2==	1
replace 	premiums2=	3321	if type1==	6	& 	type2==	2
replace 	premiums2=	4087	if type1==	6	& 	type2==	3
replace 	premiums2=	5196	if type1==	6	& 	type2==	4
replace 	premiums2=	6628	if type1==	6	& 	type2==	5
replace 	premiums2=	9647	if type1==	6	& 	type2==	6
replace 	premiums2=	10105	if type1==	6	& 	type2==	7
replace 	premiums2=	2512	if type1==	7	& 	type2==	1
replace 	premiums2=	3321	if type1==	7	& 	type2==	2
replace 	premiums2=	4087	if type1==	7	& 	type2==	3
replace 	premiums2=	5196	if type1==	7	& 	type2==	4
replace 	premiums2=	6628	if type1==	7	& 	type2==	5
replace 	premiums2=	9647	if type1==	7	& 	type2==	6
replace 	premiums2=	20507	if type1==	7	& 	type2==	7



*gen weights 30-35
gen 	weights=	0.2016	if type1==	1	& 	type2==	1
replace 	weights=	0.0576	if type1==	1	& 	type2==	2
replace 	weights=	0.0288	if type1==	1	& 	type2==	3
replace 	weights=	0.0128	if type1==	1	& 	type2==	4
replace 	weights=	0.0064	if type1==	1	& 	type2==	5
replace 	weights=	0.0064	if type1==	1	& 	type2==	6
replace 	weights=	0.0064	if type1==	1	& 	type2==	7
replace 	weights=	0.0897	if type1==	2	& 	type2==	1
replace 	weights=	0.0621	if type1==	2	& 	type2==	2
replace 	weights=	0.0368	if type1==	2	& 	type2==	3
replace 	weights=	0.0184	if type1==	2	& 	type2==	4
replace 	weights=	0.0069	if type1==	2	& 	type2==	5
replace 	weights=	0.0069	if type1==	2	& 	type2==	6
replace 	weights=	0.0069	if type1==	2	& 	type2==	7
replace 	weights=	0.0351	if type1==	3	& 	type2==	1
replace 	weights=	0.0286	if type1==	3	& 	type2==	2
replace 	weights=	0.0273	if type1==	3	& 	type2==	3
replace 	weights=	0.0195	if type1==	3	& 	type2==	4
replace 	weights=	0.0104	if type1==	3	& 	type2==	5
replace 	weights=	0.0065	if type1==	3	& 	type2==	6
replace 	weights=	0.0052	if type1==	3	& 	type2==	7
replace 	weights=	0.015	if type1==	4	& 	type2==	1
replace 	weights=	0.014	if type1==	4	& 	type2==	2
replace 	weights=	0.019	if type1==	4	& 	type2==	3
replace 	weights=	0.026	if type1==	4	& 	type2==	4
replace 	weights=	0.015	if type1==	4	& 	type2==	5
replace 	weights=	0.007	if type1==	4	& 	type2==	6
replace 	weights=	0.005	if type1==	4	& 	type2==	7
replace 	weights=	0.0104	if type1==	5	& 	type2==	1
replace 	weights=	0.0088	if type1==	5	& 	type2==	2
replace 	weights=	0.0096	if type1==	5	& 	type2==	3
replace 	weights=	0.0152	if type1==	5	& 	type2==	4
replace 	weights=	0.0184	if type1==	5	& 	type2==	5
replace 	weights=	0.012	if type1==	5	& 	type2==	6
replace 	weights=	0.0056	if type1==	5	& 	type2==	7
replace 	weights=	0.0084	if type1==	6	& 	type2==	1
replace 	weights=	0.0056	if type1==	6	& 	type2==	2
replace 	weights=	0.0063	if type1==	6	& 	type2==	3
replace 	weights=	0.0063	if type1==	6	& 	type2==	4
replace 	weights=	0.0105	if type1==	6	& 	type2==	5
replace 	weights=	0.0224	if type1==	6	& 	type2==	6
replace 	weights=	0.0105	if type1==	6	& 	type2==	7
replace 	weights=	0.0063	if type1==	7	& 	type2==	1
replace 	weights=	0.0042	if type1==	7	& 	type2==	2
replace 	weights=	0.0049	if type1==	7	& 	type2==	3
replace 	weights=	0.0049	if type1==	7	& 	type2==	4
replace 	weights=	0.0056	if type1==	7	& 	type2==	5
replace 	weights=	0.0105	if type1==	7	& 	type2==	6
replace 	weights=	0.0336	if type1==	7	& 	type2==	7


**** Use 
local acg1exp=4003
* reg variables 
gen delta_premiums =  premiums2 - premiums1
foreach X of varlist type* {
  replace `X'=837/`acg1exp' if `X'==1
  replace `X'=1376/`acg1exp' if `X'==2
  replace `X'=1973/`acg1exp' if `X'==3
  replace `X'=3052/`acg1exp' if `X'==4
  replace `X'=4358/`acg1exp' if `X'==5
  replace `X'=6840/`acg1exp' if `X'==6
  replace `X'=20507/`acg1exp' if `X'==7
}

* Implication 1 baseline, FE
gen delta_risk = type2 - type1
reg delta_premiums delta_risk [pweight=weights]


* Stratification based on period 1 risk, implication 3 FE
gen deltariskper1_1 = (type1<1)*delta_risk
gen deltariskper1_2 = (type1>=1)*delta_risk

reg delta_premiums deltarisk* [pweight=weights], nocons
drop deltariskper1*


* Spline based on changes in risk score, implication 2 FE
scatter delta_premiums delta_risk 
mkspline deltasplinerisk1 0 deltasplinerisk2 = delta_risk
reg delta_premiums deltasplinerisk1 deltasplinerisk2 [pweight=weights], nocons 
* implication 2, FEs, two dummies
gen deltarisklow=delta_risk*(delta_risk<0)
gen deltariskhigh=delta_risk*(delta_risk>=0)
gen deltarisklowconst=(delta_risk<1)
reg delta_premiums deltarisklow deltariskhigh deltarisklowconst [pweight=weights]


****************************************************
* Create two periods of data for non FE estimates
****************************************************

gen obs=_n
gen lowriskper1=(type1<1)
reshape long type premiums, i(obs) j(year)

* implication 1, no FEs
reg premiums type i.year [pweight=weights]

* implication 1, FEs
areg premiums type i.year [pweight=weights], absorb(obs)


* implication 2, no FEs
mkspline splinerisk1 1 splinerisk2 = type
xtset obs year

* implication 2, no FEs
reg premiums splinerisk* i.year [pweight=weights]

* implication 2, no FEs, two dummies
gen risklow=type*(type<1)
gen riskhigh=type*(type>=1)
gen risklowconst=(type<1)
reg premiums risklow riskhigh risklowconst i.year [pweight=weights]

*** implication 3, no FEs, based on period 1 risk
gen lowriskper1_times_risk = (lowriskper1==1)*type
gen highriskper1_times_risk = (lowriskper1==0)*type
reg premiums *riskper1_times* i.year [pweight=weights]

exit
